package com.xyd.servlet;

import com.xyd.entity.Comment;
import com.xyd.service.CommentService;
import com.xyd.service.impl.CommentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author 86186
 */
@WebServlet("/CommentByIdServlet")
public class CommentByIdServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String ecIdStr=request.getParameter("ecId");
        long ecId=Long.parseLong(ecIdStr);

        CommentService commentService=new CommentServiceImpl();

        Comment comment=commentService.getAllCommentById(ecId);
        request.setAttribute("comment",comment);

        request.getRequestDispatcher("manage/guestbook-modify.jsp").forward(request,response);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
